//
// Created by 51165 on 2025/10/13.
//
#include <stdio.h>
int main() {
    int m,n;
    scanf("%d %d",&m,&n);
    while (n!=0) {
        int temp = m % n;
        m = n;
        n = temp;
    }
    printf("%d\n", m);
    return 0;
}